<!-- 检查记录 -->
<script setup lang="ts">
import { ElMessage } from 'element-plus';

import { reactive } from 'vue';
import { addCheckLog } from '../../../api/index';
const props = defineProps<{ centerDialogVisible: boolean, type: string ,remarkId?:string}>();
const formItem = reactive({
    inspectUser: 'admin',
    type: '',
    remark: ''
})
const emit = defineEmits(['close', 'confirm'])
const cancel = () => {
    emit('close')
}
const confirm = () => {
    formItem.type = props.type;
    if (formItem.remark == '') {
        ElMessage({
            message: '请输入检查意见',
            type: 'error',
        })
        return
    }
    const params = {
        ...formItem,
        inspectLogId: props.remarkId
    }
    addCheckLog(params).then((res:any) => {
        if(res.code === 200) {
            emit('confirm');
            ElMessage.success(res.msg);
        } else {
            ElMessage.error(res.msg);
        }
        
    })
}
</script>

<template>
    <el-dialog v-model="props.centerDialogVisible" title="检查记录" width="500" center>
        <el-form v-model="formItem" label-position="left" >
            <el-form-item label="检查意见">
                <el-input v-model="formItem.remark" />
            </el-form-item>
        </el-form>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="cancel">取 消</el-button>
                <el-button type="primary" @click="confirm">
                    确 定
                </el-button>
            </div>
        </template>
    </el-dialog>
</template>

<style></style>